#pragma once

#include <string>
#include <vector>
#include <d3dx9.h>


class CCollisionController;
class IRenderingManager;
class IMeshStorage;
class ActionObject;
class Gate;
class AIAgent;
class PhysicalObject;
class IPlayersManager;
class IRaceController;
class IMovable;

class TrackLoader
{
private:
   CCollisionController& m_collisionController;
   IRenderingManager& m_renderingManager;
   IMeshStorage& m_meshStorage;
   IPlayersManager& m_playersManager;
   IRaceController& m_raceController;
   std::vector<ActionObject*>& m_activePlayers;
   std::vector<Gate*>& m_gates;
   std::vector<AIAgent*>& m_aiAgents;

   PhysicalObject* m_controlledPhysicalObject;
   ActionObject* m_controlledActionObject;
   IMovable* m_controlledMovable;

public:
   TrackLoader(CCollisionController& collisionController,
               IRenderingManager& renderingManager,
               IMeshStorage& meshStorage,
               IPlayersManager& playersManager,
               IRaceController& raceController,
               std::vector<ActionObject*>& activePlayers,
               std::vector<Gate*>& gates,
               std::vector<AIAgent*>& aiAgents);

   void load(const std::string& trackName);

   PhysicalObject* getUserControlledPhysicalObject() {return m_controlledPhysicalObject;}

   ActionObject* getUserControlledActionObject() {return m_controlledActionObject;}

   IMovable* getUserControlledMovable() {return m_controlledMovable;}

private:
   void addPlayer(const D3DXVECTOR3& position);

   void addEnemy(const D3DXVECTOR3& position);

   void addGate(const D3DXVECTOR3& pole1Pos, const D3DXVECTOR3& pole2Pos);
};
